using UnityEngine;
using UnityEditor;

namespace GPUParticles
{
    public class EmissionModule : Module
    {
        SerializedProperty enableEmission;
        SerializedProperty emissionRate;
        SerializedProperty minInitialSpeed;
        SerializedProperty maxInitialSpeed;
        SerializedProperty sphereRadius;

        public EmissionModule(SerializedObject serializedObject)
        {
            enableEmission = serializedObject.FindProperty("enableEmission");
            emissionRate = serializedObject.FindProperty("emissionRate");
            minInitialSpeed = serializedObject.FindProperty("minInitialSpeed");
            maxInitialSpeed = serializedObject.FindProperty("maxInitialSpeed");
            sphereRadius = serializedObject.FindProperty("sphereRadius");
        }

        public override void Draw()
        {
            enableEmission.boolValue = DrawGUI(enableEmission.boolValue, "Emission", DrawContent);
        }

        private void DrawContent()
        {
            EditorGUILayout.PropertyField(emissionRate, new GUIContent("Particles/sec"));
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(sphereRadius, new GUIContent("Radius"));
            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(minInitialSpeed, new GUIContent("Min Initial Speed"));
            EditorGUILayout.PropertyField(maxInitialSpeed, new GUIContent("Max Initial Speed"));
        }
    }
}